home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 5
/
Apprentice-Release5.iso
/
Source Code
/
By the Book
/
Learn C++ (CodeWarrior)
/
Chap 04.04 - reference
/
reference.cp
< prev
next >
Wrap
Text File
|
1995-10-20
|
814b
|
41 lines
#include <iostream.h>
void CallByValue( short valueParam );
void CallByReference( short &refParam );
int main()
{
short number = 12;
long longNumber = 12L;
cout << "&number: " <<
(unsigned long)&number << "\n";
cout << "&longNumber: " <<
(unsigned long)&longNumber << "\n\n";
CallByValue( number );
cout << "After ByValue: " << number << "\n\n";
CallByReference( number );
cout << "After ByRef( short ): " << number << "\n\n";
CallByReference( longNumber );
cout << "After ByRef( long ): " << longNumber << "\n";
return 0;
}
void CallByValue( short valueParam )
{
cout << "&valueParam: " <<
(unsigned long)&valueParam << "\n";
valueParam *= 2;
}
void CallByReference( short &refParam )
{
cout << "&refParam: " <<
(unsigned long)&refParam << "\n";
refParam *= 2;
}